import cn.northsea.ServiceLogisticsApplication;
import cn.northsea.mapper.*;
import cn.northsea.model.logistics.Logistics;
import cn.northsea.model.supplier.Supplier;
import cn.northsea.model.user.UserInfo;
import cn.northsea.service.LogisticsService;
import cn.northsea.service.impl.LogisticsServiceImpl;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Date;

/**
 * @Author: Siantar
 * @Date: 2024-08-24-9:12
 * @Description: 1.0
 */

@SpringBootTest(classes = ServiceLogisticsApplication.class)
public class BatchAdd {

    @Autowired
    LogisticsMapper logisticsMapper;

    @Autowired
    MaterialDetailMapper materialDetailMapper;

    @Autowired
    BuyMapper buyMapper;

    @Autowired
    UsersMapper usersMapper;

    @Autowired
    MaterialMapper materialMapper;

    @Autowired
    SupplierMapper supplierMapper;

    @Autowired
    WarehouseMapper warehouseMapper;


    @Test
    public void batchAddLogistics() {
        for (int i = 0; i < 25; i++) {
            Logistics logistics=new Logistics();
            logistics.setId((long) i);
            logistics.setType(RandomInsertUtils.getRandomFromStringArr(new String[]{"重型货车","中型货车","轻型货车"}));
            logistics.setCarNumber(RandomInsertUtils.generateLicensePlate());
            logistics.setState(RandomInsertUtils.getRandomFromIntegerArr(new Integer[]{0,1,2,3,4,5,6}));
            logisticsMapper.insert(logistics);
        }
    }

    @Test
    public void batchAddUser() {
        for (int i = 0; i < 30; i++) {
            UserInfo userInfo=new UserInfo();
            userInfo.setUsername(RandomInsertUtils.getRandomName());
            userInfo.setPassword(RandomInsertUtils.getRandomInteger(100000,999999).toString());
            userInfo.setRole(2);
            userInfo.setJob("员工");
            userInfo.setPhone(RandomInsertUtils.getRandomLong(10000000000L,19999999999L).toString());
            userInfo.setEnterTime(RandomInsertUtils.getRandomDate2(new Date(110, 1,1),new Date(124, 8, 24)));
            usersMapper.insert(userInfo);
        }
    }


    @Test
    public void batchAddSupplier() {
        for (int i = 0; i < 2; i++) {
            Supplier supplier=new Supplier();
            supplier.setName(RandomInsertUtils.getRandomChineseCompanyName());
            supplier.setPhone(RandomInsertUtils.getRandomLong(10000000000L,19999999999L).toString());
//            supplier.setAddress(RandomInsertUtils.getRandomAddress());

        }
    }
}
